home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1985 September / Ahoy_Magazine_85-09_1985_Double_L.d64 / dice analyzer (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  1KB  |  49 lines

  1. 0 rem << rr21-2 >>
  2. 1 print"[147]":poke53280,0:poke53281,6:poke646,1
  3. 2 print"-- dice analyzer --"
  4. 3 rem  rupert report #21
  5. 4 rem
  6. 5 print"enumerate all possible"
  7. 6 print"outcomes for rolling three dice"
  8. 7 rem
  9. 8 print">>calculate the probability that"
  10. 10 print"  1) 3 ones are rolled"
  11. 11 print"  2) at least 1 three and 1 six              are rolled"
  12. 12 print"  3) no twos are rolled"
  13. 13 print"  4) the sum is eleven"
  14. 14 print"    press any key";:input a$
  15. 15 rem >on the nth roll (n = 1 to 216):
  16. 16 rem roll(n,y) = die y's value
  17. 17 rem ct(n,z) = # dice with value z
  18. 18 rem ttl(n) = sum of dice values
  19. 19 rem
  20. 20 dim roll(216,3),ct(216,6),ttl(216),rnum(216)
  21. 30 n=1 : m=1 : print chr$(147)
  22. 40 for a=1 to 6 : for b=1 to 6
  23. 50 for c=1 to 6
  24. 60 print a;b;c
  25. 70 roll(n,1)=a:roll(n,2)=b:roll(n,3)=c
  26. 80 ct(n,a)=ct(n,a)+1 :ct(n,b)=ct(n,b)+1
  27. 90 ct(n,c)=ct(n,c)+1
  28. 100 ttl(n)=a+b+c
  29. 110 n=n+1 : next c : next b : next a
  30. 120 print"calculating ... "
  31. 130 for n=1 to 216
  32. 140 :if ct(n,1)=3 then t1=t1+1
  33. 150 :if ct(n,3)>=1 and ct(n,6)>=1 then t2=t2+1
  34. 160 :if ct(n,2)=0 then t3=t3+1
  35. 170 :if ttl(n)=11 then t4=t4+1:rnum(m)=n:m=m+1
  36. 180 next n
  37. 190 print
  38. 200 print,"# success"," % probability"
  39. 210 print "test 1",t1,t1*100/216
  40. 220 print "test 2",t2,t2*100/216
  41. 230 print "test 3",t3,t3*100/216
  42. 240 print "test 4",t4,t4*100/216
  43. 250 print
  44. 260 print"successful rolls for test 4:"
  45. 270 for m=1 to t4
  46. 280 rm=rnum(m)
  47. 290 print roll(rm,1);roll(rm,2);roll(rm,3),
  48. 300 next m
  49.